<template>
  <div>
    <el-button icon="el-icon-back" circle @click="back"></el-button>
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="待鉴定物证编号">
        <el-input v-model="form.wid"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="add">确定添加</el-button>
        <el-button @click="cancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "EditUser",
  data(){
    return{
      qid : '',
      form: {
        wid: ''
      }
    }
  },
  created: function() {
    this.qid=this.$route.params.qid;
  },
  methods:{
    back: function (){
      this.$router.push("/func/CidentifyList");
    },
    add:function(){
      console.log(this.form);
      this.axios({
        method:"post",
        headers: { 'content-type': 'application/json' },
        url: "http://evidence.frogking.cn/identifyUserController/insertIdentify",
        params:{
          token:localStorage.getItem("token_only"),
          wid:this.form.wid,
          qid:this.qid
        }
      }).then(res=>{
        if(res["data"]["code"]==='304'){
          this.$router.push('/func/CidentifyList')
        }
        else if(res["data"]["code"]==='305'){
          this.$alert('系统错误！添加失败！', '错误提示', {
            confirmButtonText: '确定',
            callback: action => {
                this.uid='';
                this.wtext='';
            }
          });
        }
        else if(res["data"]["code"]==='310'){
          this.$alert('添加者错误！添加异常！', '错误提示', {
            confirmButtonText: '确定',
            callback: action => {
              this.uid='';
              this.wtext='';
            }
          });
        }
        else if(res["data"]["code"]==='000'){
          this.$alert('token失效', '错误提示', {
            confirmButtonText: '确定',
            callback: action => {
              this.$router.push("/login");
              localStorage.removeItem("token_only");
            }
          });
        }
        else if(res["data"]["code"]==='001'){
          this.$alert('token权限不满足，禁止操作', '错误提示', {
            confirmButtonText: '确定'
          });
        }
        else if(res["data"]["code"]==='002'){
          this.$alert('token权限不满足，禁止操作', '错误提示', {
            confirmButtonText: '确定'
          });
        }
      }).catch(function (error) {
        console.log(error);
      });
    },
    cancel:function (){
      this.wid='';
      this.qid='';
    }
  }

}
</script>
<style scoped>

</style>
